package com.jr.javaproject;

import com.alibaba.fastjson.JSONObject;
import com.jr.javaproject.address.Address;
import com.jr.javaproject.bean.HotVideo;
import com.jr.javaproject.bean.HotVideoCommon;
import com.jr.javaproject.request.HttpUtils;
import com.jr.javaproject.rpc.GetBestBlockHash;
import com.jr.javaproject.service.HotVideoService;

import javax.crypto.SecretKey;
import java.security.KeyPair;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String []args){

        run();
    }
    public static void run(){
        System.out.println("=======比特币系统设计期末考察系统=======");
        System.out.println("本系统已实现以下功能：");
        System.out.println("1.热门视频抓取 2.和比特币客户端通信 3.比特币地址推导 0.退出");
        while (true){
            userMenu();
        }
    }
    public static void userMenu(){
        System.out.println("请输入要使用的功能序号：");
        System.out.println("1.热门视频抓取 2.和比特币客户端通信 3.比特币地址推导 0.退出");
        Scanner scanner = new Scanner(System.in);
        int num = scanner.nextInt();
        switch (num){
            case 1://热门视频抓取
                HotVideoService hotVideo = new HotVideoService();
                List<HotVideo> videoList =  hotVideo.getHotVideo();
                for (HotVideo video :videoList){
                    System.out.println(video.getShare_url());
                }
                break;
            case 2://和比特币客户端通信
                GetBestBlockHash getBestBlockHash = new GetBestBlockHash();
                System.out.println(getBestBlockHash.GetBestBlockHash());

                break;
            case 3://比特币地址推导
                Address addr =new Address();
                KeyPair keyPair=addr.generateKeys();
                String adderss = addr.newAddress(keyPair);
                boolean isValid = addr.validateAddr(adderss);
                System.out.println(isValid);
                break;
            case 0:
                System.out.println("谢谢使用，下次再见！！！");
                System.exit(0);
                break;
            default:
                System.out.println("输入有误，请重新输入");
                break;
        }


    }
}
